<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>常见错误、调试和错误处理</title>
</head>
<body>
<script>
    abc = 23;
    var abc = 23;
    alert(abc);

    function foo(parametrOne) {
        alert(parameterOne);
    }

    var myName = 'Jeremy';
    If(myName == 'jeremy');
    {
        alert(myName.toLocaleUppercase());
    }

    //    function myFunction() {
    //        var x = 1;
    //        var y = 2;
    //        if (x <= y) {
    //            if (x == y) {
    //                alert('x equals y');
    //            }
    //        }

    myFunction();

    //    if (myVariable+12)/myOtherVariable<myString.length)

    var myNumber = 99;
    if (myNumber = 101) {
        alert('myNumber is 101');
    } else {
        alert('myNumber is ' + myNumber);
    }

    var nowDate = new Date();
    alert(nowDate.getMonth);

    var nowDate = new Date();
    alert(nowDate.getMonth());

    var myString = new String('Hello');
    alert(myString.length());

    var myString = new String('Hello');
    alert(myString.length);

    var myName = 'Jeremy';
    var myString = 'Hello';
    var myOtherString = 'world';
    //    myString = myName + ' said '+ myString + ' ' myOtherString;
    //    alert(myString);
</script>
<script>
    try {
        alert('This is code inside the try clause');
        ablert('No Errors so cathch code will not execute');
    } catch (execption) {
        alert('The error is ' + execption.message);
    }
</script>
<script>
    try {
        alert('This is code inside the try clause');
        // alert('This code won' work');
    } catch (execption) {
        alert('The error is ' + execption.message);
    }
</script>
<script>
    throw{
        message: 'Please type a valid email address',
        elementId: 'textEmail'
    }
</script>
<script>
    try {
        try {
            ablurt('This code has an error');
        } catch (e) {
            var name = e.name;
            if (name == 'TypeError' || name == 'ReferenceError') {
                alert('Inner try...cath can deal with this error');
            } else {
                throw e;
            }
        }
    } catch (ex) {
        alert('The inner try...catch could not handle the exception.');
    }
</script>
<script>
    try {
        abluret('An exception will occur');
    } catch (e) {
        alert('Execption occurred');
    } finally {
        alert('This line always executes');
    }
</script>
<script>
    function writeTimesTable(number) {
        var writeString;
        for (var i = 0; i < 12; i++) {
            writeString = i + ' * ' + number + ' = ';
            writeString += (number * i);
            writeString += '<br/>';
            document.write(writeString);
        }
    }

    writeTimesTable(2);
</script>
<script>
    function writeTimesTable(number) {
        var writeString;
        for (var i = 0; i < 12; i++) {
            writeString = i + ' * ' + number + ' = ';
            writeString += (number * i);
            writeString += '<br/>';
            document.write(writeString);
        }
    }

    for (var i = 0; i <= 12; i++) {
        document.write('<p>');
        writeTimesTable(i);
        document.write('</p>');
    }
</script>
<script>
    document.write(writeString);
    writeString = 'Changed on the Fly<br/>';
    timesTable <= 12;
</script>
<input id="button" type="button" name="button" value="Button">
<script>
    function firstCall() {
        secondCall();
    }

    function secondCall() {
        thirdCall();
    }

    function thirdCall() {

    }

    function buttonClick() {
        debugger;
        firstCall();
    }

    document.getElementById('button').addEventListener('click', buttonClick);
</script>
</body>
</html>